package thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo16 {
    public static void main(String[] args) {
        //创建固定线程数的线程池
        ExecutorService pool1 = Executors.newFixedThreadPool(10);
        //创建线程数目动态增长的线程池
        ExecutorService pool2 = Executors.newCachedThreadPool();
        //创建只包含一个线程的线程池
        ExecutorService pool3 = Executors.newSingleThreadExecutor();
        //设定延时后执行命令
        ExecutorService pool4 = Executors.newScheduledThreadPool(100);
        pool1.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println("pool1");
            }
        });
        pool2.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println("pool2");
            }
        });
        pool3.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println("pool3");
            }
        });
        pool4.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println("pool4");
            }
        });
    }
}
